﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using AnalisisDeRiesgos.Dal;

namespace AnalisisDeRiesgos.Models.User
{
    public class LogOffModel
    {
        public String UserName { get; set; }

        public void FillUserByCI(int userCI)
        {            
            riskanalysisEntities entities = new riskanalysisEntities();
            var theUsers = from u in entities.users
                            where u.CI == userCI && u.enabled
                            select new { UserName = u.firstName + " " + u.lastName + " " + u.secondLastName };
            if (theUsers.Count() >= 1)
                UserName = theUsers.FirstOrDefault().UserName;
            else
                UserName = "Anonimo";
            
        }
    }
}